import CryptoJS from 'crypto-js'

// 加密
export function encrypt(data, key) {
  const ciphertext = CryptoJS.AES.encrypt(data, key).toString()
  return ciphertext
}

// 解密
export function decrypt(ciphertext, key) {
  const bytes = CryptoJS.AES.decrypt(ciphertext, key)
  const originalText = bytes.toString(CryptoJS.enc.Utf8)
  return originalText
}